package com.taxsystem.gaozhuanglin.booking;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.main.taxsystem.R;
import com.taxsystem.tool.HttpUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class TimeSliceActivity extends Activity {
	
	ListView timeSliceList;
	private String [] timeSlices = {"8:00-8:30", "8:30-9:00"};
	private int [] bookCounts = {1, 2};
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.time_slice);
		
		timeSliceList = (ListView)findViewById(R.id.timeSlices);
		
		List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>();
		for(int i = 0; i < timeSlices.length; i++)
		{
			Map<String, Object> listItem = new HashMap<String, Object>();
			listItem.put("timeSlice", timeSlices[i]);
			listItem.put("bookCount", "剩余预约数："+bookCounts[i]);
			listItems.add(listItem);
		}
		
		SimpleAdapter simpleAdapter = new SimpleAdapter(this, listItems, R.layout.time_slice_item, new String[]{"timeSlice", "bookCount"}, new int[]{R.id.time, R.id.bookCount});
		timeSliceList.setAdapter(simpleAdapter);
		
		timeSliceList.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Intent intent4 = new Intent(TimeSliceActivity.this, CommitActivity.class);
				/*intent4.putExtra("areaId", 1);
				intent4.putExtra("bookingDateIdx", 866);
				intent4.putExtra("bookingDate", "2014-05-15+00%3A00%3A00");
				intent4.putExtra("bookstarttime", "2014-05-15+12%3A00%3A00");
				intent4.putExtra("bookendtime", "2014-05-15+12%3A30%3A00");
				intent4.putExtra("timesliceId", 9);
				intent4.putExtra("bookticketitmeid", 200306);
				intent4.putExtra("bookremarks", "1111111111111111111111");
				intent4.putExtra("bookcounterid", 0);
				intent4.putExtra("bookidentity", 123);
				intent4.putExtra("operatorid", 58);*/
				startActivity(intent4);
			}
			
		});
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main_tab, menu);
		return true;
	}
	
}
